package com.trigram.dao.dynamic.mapper.dynamic;

import com.trigram.dao.dynamic.entity.po.MaindataEntity;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.SelectProvider;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.CommonCountMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonDeleteMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonInsertMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonUpdateMapper;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

public interface MaindataDynamicSql
    extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<MaindataEntity>, CommonUpdateMapper {

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  BasicColumn[] selectList = BasicColumn.columnList(
      MaindataEntityDynamicSqlSupport.modelid, MaindataEntityDynamicSqlSupport.year,
      MaindataEntityDynamicSqlSupport.totoperrev, MaindataEntityDynamicSqlSupport.totoperrevyoy,
      MaindataEntityDynamicSqlSupport.netprofitincl, MaindataEntityDynamicSqlSupport.netprofitinclyoy,
      MaindataEntityDynamicSqlSupport.windnetprofit, MaindataEntityDynamicSqlSupport.eps,
      MaindataEntityDynamicSqlSupport.netassetvaluepershare, MaindataEntityDynamicSqlSupport.pe,
      MaindataEntityDynamicSqlSupport.pb, MaindataEntityDynamicSqlSupport.ps, MaindataEntityDynamicSqlSupport.ev,
      MaindataEntityDynamicSqlSupport.peg, MaindataEntityDynamicSqlSupport.updatetime,
      MaindataEntityDynamicSqlSupport.type
  );

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  static UpdateDSL<UpdateModel> updateAllColumns(MaindataEntity row, UpdateDSL<UpdateModel> dsl) {

    return dsl.set(MaindataEntityDynamicSqlSupport.modelid).equalTo(row::getModelid)
        .set(MaindataEntityDynamicSqlSupport.year).equalTo(row::getYear)
        .set(MaindataEntityDynamicSqlSupport.totoperrev).equalTo(row::getTotoperrev)
        .set(MaindataEntityDynamicSqlSupport.totoperrevyoy).equalTo(row::getTotoperrevyoy)
        .set(MaindataEntityDynamicSqlSupport.netprofitincl).equalTo(row::getNetprofitincl)
        .set(MaindataEntityDynamicSqlSupport.netprofitinclyoy).equalTo(row::getNetprofitinclyoy)
        .set(MaindataEntityDynamicSqlSupport.windnetprofit).equalTo(row::getWindnetprofit)
        .set(MaindataEntityDynamicSqlSupport.eps).equalTo(row::getEps)
        .set(MaindataEntityDynamicSqlSupport.netassetvaluepershare).equalTo(row::getNetassetvaluepershare)
        .set(MaindataEntityDynamicSqlSupport.pe).equalTo(row::getPe)
        .set(MaindataEntityDynamicSqlSupport.pb).equalTo(row::getPb)
        .set(MaindataEntityDynamicSqlSupport.ps).equalTo(row::getPs)
        .set(MaindataEntityDynamicSqlSupport.ev).equalTo(row::getEv)
        .set(MaindataEntityDynamicSqlSupport.peg).equalTo(row::getPeg)
        .set(MaindataEntityDynamicSqlSupport.updatetime).equalTo(row::getUpdatetime)
        .set(MaindataEntityDynamicSqlSupport.type).equalTo(row::getType);
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  static UpdateDSL<UpdateModel> updateSelectiveColumns(MaindataEntity row, UpdateDSL<UpdateModel> dsl) {

    return dsl.set(MaindataEntityDynamicSqlSupport.modelid).equalToWhenPresent(row::getModelid)
        .set(MaindataEntityDynamicSqlSupport.year).equalToWhenPresent(row::getYear)
        .set(MaindataEntityDynamicSqlSupport.totoperrev).equalToWhenPresent(row::getTotoperrev)
        .set(MaindataEntityDynamicSqlSupport.totoperrevyoy).equalToWhenPresent(row::getTotoperrevyoy)
        .set(MaindataEntityDynamicSqlSupport.netprofitincl).equalToWhenPresent(row::getNetprofitincl)
        .set(MaindataEntityDynamicSqlSupport.netprofitinclyoy).equalToWhenPresent(row::getNetprofitinclyoy)
        .set(MaindataEntityDynamicSqlSupport.windnetprofit).equalToWhenPresent(row::getWindnetprofit)
        .set(MaindataEntityDynamicSqlSupport.eps).equalToWhenPresent(row::getEps)
        .set(MaindataEntityDynamicSqlSupport.netassetvaluepershare).equalToWhenPresent(row::getNetassetvaluepershare)
        .set(MaindataEntityDynamicSqlSupport.pe).equalToWhenPresent(row::getPe)
        .set(MaindataEntityDynamicSqlSupport.pb).equalToWhenPresent(row::getPb)
        .set(MaindataEntityDynamicSqlSupport.ps).equalToWhenPresent(row::getPs)
        .set(MaindataEntityDynamicSqlSupport.ev).equalToWhenPresent(row::getEv)
        .set(MaindataEntityDynamicSqlSupport.peg).equalToWhenPresent(row::getPeg)
        .set(MaindataEntityDynamicSqlSupport.updatetime).equalToWhenPresent(row::getUpdatetime)
        .set(MaindataEntityDynamicSqlSupport.type).equalToWhenPresent(row::getType);
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  @SelectProvider(type = SqlProviderAdapter.class, method = "select")
  @ResultMap("BaseResultMap")
  List<MaindataEntity> selectMany(SelectStatementProvider selectStatement);

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  @SelectProvider(type = SqlProviderAdapter.class, method = "select")
  @ResultMap("BaseResultMap")
  Optional<MaindataEntity> selectOne(SelectStatementProvider selectStatement);

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  default long count(CountDSLCompleter completer) {

    return MyBatis3Utils.countFrom(this::count, MaindataEntityDynamicSqlSupport.maindataEntity, completer);
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  default int delete(DeleteDSLCompleter completer) {

    return MyBatis3Utils.deleteFrom(this::delete, MaindataEntityDynamicSqlSupport.maindataEntity, completer);
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  default int insert(MaindataEntity row) {

    return MyBatis3Utils.insert(this::insert, row, MaindataEntityDynamicSqlSupport.maindataEntity, c ->
        c.map(MaindataEntityDynamicSqlSupport.modelid).toProperty("modelid")
            .map(MaindataEntityDynamicSqlSupport.year).toProperty("year")
            .map(MaindataEntityDynamicSqlSupport.totoperrev).toProperty("totoperrev")
            .map(MaindataEntityDynamicSqlSupport.totoperrevyoy).toProperty("totoperrevyoy")
            .map(MaindataEntityDynamicSqlSupport.netprofitincl).toProperty("netprofitincl")
            .map(MaindataEntityDynamicSqlSupport.netprofitinclyoy).toProperty("netprofitinclyoy")
            .map(MaindataEntityDynamicSqlSupport.windnetprofit).toProperty("windnetprofit")
            .map(MaindataEntityDynamicSqlSupport.eps).toProperty("eps")
            .map(MaindataEntityDynamicSqlSupport.netassetvaluepershare).toProperty("netassetvaluepershare")
            .map(MaindataEntityDynamicSqlSupport.pe).toProperty("pe")
            .map(MaindataEntityDynamicSqlSupport.pb).toProperty("pb")
            .map(MaindataEntityDynamicSqlSupport.ps).toProperty("ps")
            .map(MaindataEntityDynamicSqlSupport.ev).toProperty("ev")
            .map(MaindataEntityDynamicSqlSupport.peg).toProperty("peg")
            .map(MaindataEntityDynamicSqlSupport.updatetime).toProperty("updatetime")
            .map(MaindataEntityDynamicSqlSupport.type).toProperty("type")
    );
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  default int insertMultiple(Collection<MaindataEntity> records) {

    return MyBatis3Utils.insertMultiple(
        this::insertMultiple, records, MaindataEntityDynamicSqlSupport.maindataEntity, c ->
            c.map(MaindataEntityDynamicSqlSupport.modelid).toProperty("modelid")
                .map(MaindataEntityDynamicSqlSupport.year).toProperty("year")
                .map(MaindataEntityDynamicSqlSupport.totoperrev).toProperty("totoperrev")
                .map(MaindataEntityDynamicSqlSupport.totoperrevyoy).toProperty("totoperrevyoy")
                .map(MaindataEntityDynamicSqlSupport.netprofitincl).toProperty("netprofitincl")
                .map(MaindataEntityDynamicSqlSupport.netprofitinclyoy).toProperty("netprofitinclyoy")
                .map(MaindataEntityDynamicSqlSupport.windnetprofit).toProperty("windnetprofit")
                .map(MaindataEntityDynamicSqlSupport.eps).toProperty("eps")
                .map(MaindataEntityDynamicSqlSupport.netassetvaluepershare).toProperty("netassetvaluepershare")
                .map(MaindataEntityDynamicSqlSupport.pe).toProperty("pe")
                .map(MaindataEntityDynamicSqlSupport.pb).toProperty("pb")
                .map(MaindataEntityDynamicSqlSupport.ps).toProperty("ps")
                .map(MaindataEntityDynamicSqlSupport.ev).toProperty("ev")
                .map(MaindataEntityDynamicSqlSupport.peg).toProperty("peg")
                .map(MaindataEntityDynamicSqlSupport.updatetime).toProperty("updatetime")
                .map(MaindataEntityDynamicSqlSupport.type).toProperty("type")
    );
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  default int insertSelective(MaindataEntity row) {

    return MyBatis3Utils.insert(this::insert, row, MaindataEntityDynamicSqlSupport.maindataEntity, c ->
        c.map(MaindataEntityDynamicSqlSupport.modelid).toPropertyWhenPresent("modelid", row::getModelid)
            .map(MaindataEntityDynamicSqlSupport.year).toPropertyWhenPresent("year", row::getYear)
            .map(MaindataEntityDynamicSqlSupport.totoperrev).toPropertyWhenPresent("totoperrev", row::getTotoperrev)
            .map(MaindataEntityDynamicSqlSupport.totoperrevyoy)
            .toPropertyWhenPresent("totoperrevyoy", row::getTotoperrevyoy)
            .map(MaindataEntityDynamicSqlSupport.netprofitincl)
            .toPropertyWhenPresent("netprofitincl", row::getNetprofitincl)
            .map(MaindataEntityDynamicSqlSupport.netprofitinclyoy)
            .toPropertyWhenPresent("netprofitinclyoy", row::getNetprofitinclyoy)
            .map(MaindataEntityDynamicSqlSupport.windnetprofit)
            .toPropertyWhenPresent("windnetprofit", row::getWindnetprofit)
            .map(MaindataEntityDynamicSqlSupport.eps).toPropertyWhenPresent("eps", row::getEps)
            .map(MaindataEntityDynamicSqlSupport.netassetvaluepershare)
            .toPropertyWhenPresent("netassetvaluepershare", row::getNetassetvaluepershare)
            .map(MaindataEntityDynamicSqlSupport.pe).toPropertyWhenPresent("pe", row::getPe)
            .map(MaindataEntityDynamicSqlSupport.pb).toPropertyWhenPresent("pb", row::getPb)
            .map(MaindataEntityDynamicSqlSupport.ps).toPropertyWhenPresent("ps", row::getPs)
            .map(MaindataEntityDynamicSqlSupport.ev).toPropertyWhenPresent("ev", row::getEv)
            .map(MaindataEntityDynamicSqlSupport.peg).toPropertyWhenPresent("peg", row::getPeg)
            .map(MaindataEntityDynamicSqlSupport.updatetime).toPropertyWhenPresent("updatetime", row::getUpdatetime)
            .map(MaindataEntityDynamicSqlSupport.type).toPropertyWhenPresent("type", row::getType)
    );
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  default Optional<MaindataEntity> selectOne(SelectDSLCompleter completer) {

    return MyBatis3Utils.selectOne(
        this::selectOne, selectList, MaindataEntityDynamicSqlSupport.maindataEntity, completer);
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  default List<MaindataEntity> select(SelectDSLCompleter completer) {

    return MyBatis3Utils.selectList(
        this::selectMany, selectList, MaindataEntityDynamicSqlSupport.maindataEntity, completer);
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  default List<MaindataEntity> selectDistinct(SelectDSLCompleter completer) {

    return MyBatis3Utils.selectDistinct(
        this::selectMany, selectList, MaindataEntityDynamicSqlSupport.maindataEntity, completer);
  }

  @Generated(comments = "Source Table: QYYJMX.T_IRM_EXCEL_MAINDATA", value = {})
  default int update(UpdateDSLCompleter completer) {

    return MyBatis3Utils.update(this::update, MaindataEntityDynamicSqlSupport.maindataEntity, completer);
  }

}